package com.ndbg.demo.acting;

import com.ndbg.demo.service.user.service.IUserService;
import org.springframework.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;

public class UserServiceHandler implements InvocationHandler {

    private IUserService userService;

    public UserServiceHandler(IUserService userService) {
        this.userService = userService;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("操作开始运行，操作类型是："+method.getName());
        Object res = method.invoke(userService, args);
        System.out.println(method.getName()+"运行结束");
        System.out.println();
        return res;
    }
}
